package br.com.ifet.classes.projetoandroidmobile;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;

public class Cadastro extends Activity {
	
	private Intent itCadastroToPrincipal;
	private Intent itCadastroToHome;
	private ImageButton btnEsq;
	private ImageButton btnDir;
	private ImageView imgAvatar;
	private Button btnVoltar;
	private Button btnEnviar;
	private int aux;
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.cadastro);
        itCadastroToPrincipal = new Intent(Cadastro.this, Principal.class);
        itCadastroToHome = new Intent(Cadastro.this, Home.class);
        btnEsq = (ImageButton) findViewById(R.id.btnEsq);
        btnDir = (ImageButton) findViewById(R.id.btnDir);
        imgAvatar = (ImageView) findViewById(R.id.imgAvatar);
        btnVoltar = (Button) findViewById(R.id.btnVoltar);
        btnEnviar = (Button) findViewById(R.id.btnEnviar);
        aux = 1;
        
        btnEsq.setOnClickListener(new OnClickListener() {
        	public void onClick(View arg0){
        		if (aux==1) {
        			aux=3;
        			imgAvatar.setImageResource(R.drawable.and3);
        		} else if (aux==2) {
        			aux--;
        			imgAvatar.setImageResource(R.drawable.and1);
        		} else {
        			aux--;
        			imgAvatar.setImageResource(R.drawable.and2);
        		}
        	}
        });
        
        btnDir.setOnClickListener(new OnClickListener() {
        	public void onClick(View arg0){
        		if (aux==3) {
        			aux=1;
        			imgAvatar.setImageResource(R.drawable.and1);
        		} else if (aux==2) {
        			aux++;
        			imgAvatar.setImageResource(R.drawable.and3);
        		} else {
        			aux++;
        			imgAvatar.setImageResource(R.drawable.and2);
        		}
        	}
        });
        
        btnVoltar.setOnClickListener(new OnClickListener() {
        	public void onClick(View arg0){
        		startActivity(itCadastroToPrincipal);
        	}
        });
        
        btnEnviar.setOnClickListener(new OnClickListener() {
        	public void onClick(View arg0){
        		itCadastroToHome.putExtra("idImagem", aux);
        		startActivity(itCadastroToHome);
        	}
        });
	}
}
